const express = require('express')
const cookieParser = require('cookie-parser');
const expressSession = require("express-session");
const app = express();
app.use(cookieParser())
app.use(expressSession({
    secret:'miyao',
    cookie:{
        maxAge:1000*60*10
    },
    resave:false,
    saveUninitialized: false
}   
))
app.get('/add',(req,res)=>{
    req.session.name='张辉',
    req.session.age='666'
    res.send('添加session')
})
app.get('/chakan',(req,res)=>{
    console.log(req.session);
    res.send('查看session')
})
app.get('/shan',(req,res)=>{
    req.session.destroy();
    res.send('删除')
})
app.listen(5000,err=>{
    if(!err)console.log('启动成功');
    else console.log(err);
})